//
//  CarDetailInfoController.m
//  HuLaQuan
//
//  Created by hok on 3/16/16.
//  Copyright © 2016 yuwubao. All rights reserved.
//

#import "CarDetailInfoController.h"

//Cells
#import "CarDetailInfoCell.h"


@interface CarDetailInfoController ()<UIActionSheetDelegate>

@property (nonatomic,strong) NSMutableArray *items;

@end

static NSString * const CarDetailInfoCellIdentifier = @"CarDetailInfoCell";

@implementation CarDetailInfoController
- (NSDictionary *)carInfo
{
    if (!_carInfo) {
        _carInfo =@{@"title":@"单笔",@"info":@"5万"};
    }
    return _carInfo;
}
- (NSMutableArray *)items
{
    if (!_items) {
        _items = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"CarInfoItems" ofType:@"plist"]];
    }
    return _items;
}
- (void)setupUI
{
    [self setupNavBackButton];
    
    [self setupFooterForTableView];
    
    [self.tableView registerNib:[CarDetailInfoCell nib] forCellReuseIdentifier:CarDetailInfoCellIdentifier];
    
    self.title = @"车辆详情";
    
    
    [self createNavigationBarRightBarButtonItemWithTitle:@"编辑"];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)rightAction
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"车辆"
                                  delegate:self
                                  cancelButtonTitle:@"取消"
                                  destructiveButtonTitle:nil
                                  otherButtonTitles: nil];
    
    
    
    [actionSheet addButtonWithTitle:@"解除绑定"];
    
    
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [actionSheet showInView:self.view];
}

#pragma mark UITableViewDataSource

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return kNormalCellHeight;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
    
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.items.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return kUserCenterSectionHeaderHeight;
    }else if(section == 1){
        return 30;
    }else{
        return 0.00001;
    }
    
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    CarDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:CarDetailInfoCellIdentifier
                                                                   forIndexPath:indexPath];
    cell.titleLabel.text = self.items[indexPath.section];
    
//    if (indexPath.row == 0) {
//        cell.infoLabel.text = ServerMoneyToShow(self.carInfo[@"singleQuota"]) ;
//    }else{
//        cell.infoLabel.text = ServerMoneyToShow(self.carInfo[@"dayQuota"]) ;
//    }
    //    cell.infoLabel.text = self.items[indexPath.row][@"info"];
    return cell;
    
    
    
    
    
}
#pragma mark - Action Sheet
//点击按钮时触发的方法
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    
    NSLog(@"buttonIndex:%ld",buttonIndex);
    // _index = buttonIndex-1;
    if (buttonIndex != 0) {
//        [self performSegueWithIdentifier:@"ShowCardCheckFromCardInfo" sender:self];
    }
    
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
